package a3;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.SimpleDirectedWeightedGraph;
import useful.*;

public class GKAA3 {
    public static void main(String ... args) throws FileNotFoundException, IOException {
		BufferedReader br = new BufferedReader(new FileReader("src\\Graph2.graph"));
        String str = null;
        String whatgraph = br.readLine();
        SimpleDirectedWeightedGraph<String, DefaultWeightedEdge> sg = new SimpleDirectedWeightedGraph<>(DefaultWeightedEdge.class);
        
        while ((str = br.readLine()) != null) {
                String[] parts = str.split(",");
				sg.addVertex(parts[0]);
                sg.addVertex(parts[1]);
                DefaultWeightedEdge edge = sg.addEdge(parts[0], parts[1]);
                sg.setEdgeWeight(edge, Double.parseDouble(parts[2]));
        }
		
		EdmondKarp ek = new EdmondKarp();
		FordFulkerson ff = new FordFulkerson();
		System.out.println("Edmon Karp: ");
		System.out.println("Maximaler Fluss: " + ek.GetMaximalFlow(sg, "Quelle", "Senke"));
		System.out.println("Zugriffe: " + ek.GetLastAccessCount());
		System.out.println();
		System.out.println("Ford Fulkerson: ");
		System.out.println("Maximaler Fluss: " + ff.GetMaximalFlow(sg, "Quelle", "Senke"));
		System.out.println("Zugriffe: " + ff.GetLastAccessCount());
    }
}
